{include file="public/header" /}
</head>
<body>
<div id="box" v-cloak class="box">
	<div style="padding:10px;text-align:right">
		<el-button type="primary" size="small" icon="el-icon-plus" @click="add();">添加标签</el-button>
	</div>
	<el-table size="small" :data = "list" border>
		<el-table-column type="index" width="50"></el-table-column>
		<el-table-column prop="name" label="标签名"></el-table-column>
		<el-table-column prop="article_num" label="文章数量"></el-table-column>
		<el-table-column prop="create_time" label="创建时间"></el-table-column>
		<el-table-column label="操作" width="100">
			<template slot-scope="scope">
	        	<el-button @click="deleteBadge(scope.row.id)" type="text" size="small">删除</el-button>
	      	</template>
		</el-table-column>
	</el-table>
</div>
<script>
var vm = new Vue({
	el : '#box',
	data:{
		list : {$list | raw}
	},
	mounted:function(){},
	methods:{
		add:function(){
			layer.open({
				type: 2,
			  	title: '添加标签',
			  	shadeClose: true,
			  	offset: 'c',
			  	area: ['300px', '230px'],
			  	content: '{:url("addBadge")}' //iframe的url
			}); 
		},
		deleteBadge:function(id){
			var that = this;
			$.post("{:url('deleteBadge')}",{id:id},function(res){
				if(res.code){
					toastSuccess(that,res.msg,function(){
						location.reload();
					});
				}else{
					toastError(that,res.msg);
				}
			});
		}
	}
});
</script>
</body>
</html>